/*
 * Copyright 2007. Mount Sinai Hospital, Toronto, Canada.
 * 
 * Licensed under the GNU Lesser General Public License, Version 2. You
 * can find a copy of the license at:
 * 
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
 * 
 * IN NO EVENT SHALL MOUNT SINAI HOSPITAL BE LIABLE TO ANY PARTY FOR DIRECT, 
 * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST 
 * PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, 
 * EVEN IF MOUNT SINAI HOSPITAL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 
 * DAMAGE.
 * 
 * MOUNT SINAI HOSPITAL SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF 
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE AND 
 * ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". 
 * MOUNT SINAI HOSPITAL HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, 
 * UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 
 */
package com.sinai.mshab.client.ui.pages;

import com.google.gwt.user.client.ui.Hyperlink;

public class PageLink extends Hyperlink implements SidePanelItem {

	/**
	 * The unique identifier.
	 */
	private String id;

	/**
	 * Creates a new PageLink showing the text, <code>text</code> and links to
	 * the history token <code>targetHistoryToken</code>. PageLink
	 * automatically sets its id to <code>text</code>.
	 * 
	 * @param text
	 *            the text to display for this PageLink.
	 * @param targetHistoryToken
	 *            what the history token will change to.
	 */
	public PageLink(String text, String targetHistoryToken) {
		super(text, targetHistoryToken);
		setId(text);
		setStyleName("mshabPanelItem");
	}

	/**
	 * Creates a new PageLink showing the text, <code>text</code> and links to
	 * the history token <code>targetHistoryToken</code>. PageLink
	 * automatically sets its id to <code>text</code>.
	 * 
	 * @param text
	 *            the text to display for this PageLink.
	 * @param asHTML
	 *            treats <b>text</b> as HTML.
	 * @param targetHistoryToken
	 *            what the history token will change to.
	 */
	public PageLink(String text, boolean asHTML, String targetHistoryToken) {
		super(text, asHTML, targetHistoryToken);
		setId(text);
		setStyleName("mshabPanelItem");
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public int hashCode() {
		final int PRIME = 31;
		int result = 1;
		result = PRIME * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		final PageLink other = (PageLink) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
}
